package com.wangwenshuo.goods.controller;

import com.github.pagehelper.PageInfo;
import com.wangwenshuo.goods.entity.Goods;
import com.wangwenshuo.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("selects")
    public Object selectGoods(@RequestBody Goods goods, @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "3")Integer pageSize){
        System.out.println(goods);
        PageInfo<Goods> goodses = goodsService.selectGoods(goods, pageNum, pageSize);

        goodses.getList().forEach(System.out::println);
        return goodses;
    }
    @RequestMapping("del")
    public Object del(String ids){
        return goodsService.del(ids);
    }

    @RequestMapping("getById")
    public Object getById(Integer id){
        return goodsService.getById(id);
    }

    @RequestMapping("save")
    public Object del(@RequestBody Goods goods){
        return goodsService.save(goods);
    }


}
